package edu.uaskl.jqf.model.matrix;

import edu.uaskl.jqf.model.Complex;

/**
 * A Quadratic Matrix is guaranteed to have the same number of rows and columns.
 * 
 * @author tbach
 * 
 */
public class MatrixComplexQuadratic extends MatrixComplex {

    private final int size;

    public MatrixComplexQuadratic(final int size) {
        super(size, size);
        this.size = size;
    }

    public MatrixComplexQuadratic(final int size, final Complex defaultValue) {
        super(size, size, defaultValue);
        this.size = size;
    }

    public MatrixComplexQuadratic(final Complex[][] values) {
        super(values);
        this.size = values.length;
        check();
    }

    public MatrixComplexQuadratic(final double[][] values) {
        super(values);
        this.size = values.length;
        check();
    }

    public int getSize() {
        return size;
    }

    private void check() {
        for (final Complex[] row : values)
            if (row.length != size)
                throw new IllegalStateException("Matrix is not quadratic. Expected row length: " + size + ", found: " + row.length);
    }
}
